<?php
/**
 * mongodb连接类
 */
class Mongo_db{
    public $mongo;
    public $db;
    private $dbName = 'hs';
    private $host = 'localhost';
    private $port = '27017';
	/**
	 * 
	 * @param array $cfg 配置参数
	 * 			<p>db:要连接的DB名称
	 */
    public function __construct($cfg=array()){
        $this->dbName = empty($cfg['db']) ? $this->dbName : $cfg['db'];
        $this->mongo = new MongoClient($this->host . ':' . $this->port);
        $this->db = $this->mongo->selectDB($this->dbName);
    }
	/**
	 * 选择集合
	 * @param string $collName
	 */
    public function selectCollection($collName){
        return $this->db->selectCollection($collName);
    }
}

